Ext.define('DragonApp.view.broadcast.Window', {
    extend: 'Ext.window.Window',
    alias: 'widget.broadcast_window',

    requires: ['DragonApp.view.pub.combobox.MultiServer'],
    layout: 'center',

    bind: {
        title: '{title}'
    },
    closable: true,
    modal: true,

    items: [{
        xtype: 'form',
        padding: 10,
        modelValidation: true,
        reference: 'broadcast_form',
        layout: {
            type: 'fit',
            align: 'stretch'
        },
        items: [{
            xtype: 'fieldset',
            width: 780,
            height: 310,
            title: '广播信息',
            layout: 'anchor',
            padding: '15 20 15 20',
            defaults: {
                afterLabelTextTpl: DragonApp.util.String.required,
                anchor: '100%',
                xtype: 'textfield',
                msgTarget: 'side',
                labelWidth: 80
            },
            items: [{
                    xtype: 'hiddenfield',
                    fieldLabel: '广播ID',
                    name: 'id'
                },
                {
                    fieldLabel: '适用服务器',
                    xtype: 'multiservercombo',
                    allowBlank: false,
                    emptyText: '请选择',
                    name: 'server'
                },
                {
                    xtype: 'fieldcontainer',
                    layout: 'hbox',
                    items: [{
                            afterLabelTextTpl: DragonApp.util.String.required,
                            labelWidth: 80,
                            fieldLabel: '开始时间',
                            xtype: 'datetimefield',
                            format: 'Y-m-d H:i:s',
                            name: 'start_time',
                            width: 250,
                            margin: '0 18 0 0',
                            allowBlank: false,
                            emptyText: '请选择'
                        },
                        {
                            afterLabelTextTpl: DragonApp.util.String.required,
                            labelWidth: 80,
                            fieldLabel: '截止时间',
                            xtype: 'datetimefield',
                            format: 'Y-m-d H:i:s',
                            name: 'end_time',
                            width: 250,
                            margin: '0 18 0 0',
                            allowBlank: false,
                            emptyText: '请选择'
                        },
                        {
                            afterLabelTextTpl: DragonApp.util.String.required,
                            fieldLabel: '时间间隔',
                            xtype: 'numberfield',
                            name: 'interval',
                            minValue: 1,
                            width: 200,
                            allowBlank: false,
                            emptyText: '单位（秒）'
                        }
                    ]
                },
                {
                    xtype: 'textarea',
                    fieldLabel: '正文',
                    name: 'content',
                    height: 200,
                    allowBlank: false,
                    emptyText: '请输入',
                    maxLength: 50,
                    maxLengthText: '最大字符数为 {0} 个字符'
                },
                {
                    xtype: 'hiddenfield',
                    fieldLabel: '表单类型',
                    name: 'type',
                    itemId: 'formtype'
                }
            ]
        }]
    }],
    dockedItems: [{
        xtype: 'toolbar',
        dock: 'bottom',
        ui: 'footer',
        layout: {
            pack: 'end',
            type: 'hbox'
        },
        items: [{
            xtype: 'button',
            text: '取消',
            iconCls: 'x-fa fa-times',
            listeners: {
                click: 'onCancel'
            }
        }, {
            xtype: 'button',
            text: '保存',
            iconCls: 'x-fa fa-check',
            listeners: {
                click: 'onSave'
            }
        }]
    }]
});